﻿#pragma once

#include "Input/MouseEventType.h"
#include "Input/MouseButton.h"

#include "MouseState.h"

#include "Math/IntPoint.h"

#include "Path/Path.h"
#include "Containers/Delegate.h"

#include "MouseEvent.m.h"

RSTRUCT()
struct WHENGINE_API SMouseButtonEvent
{
    ROBJECT
public:
    uint64_t WindowID;
    EMouseEventType Type=EMouseEventType::Unknow;
    EMouseButton Button=EMouseButton::UnSupportedButton;
    SIntPoint MoveDistance=SIntPoint(0,0);
    //how manay times the wheel rolled
    int64_t WheelDistance=.0f;
    bool DoubleClick=false;
    //for drag/drop file event
    TVector<SPath> FilePaths;   

    RFUNCTION()
    uint64_t GetWindowID() const;

    static bool IsButtonPressed(EMouseButton Button);

    //获取鼠标在屏幕上的位置
    //默认只有在鼠标在窗口内时才会返回正确的位置
    //如果鼠标不在窗口内，返回0,0，除非某个窗口捕获了鼠标
    static SIntPoint GetMosuePositionOnScreen();
    
    EMouseEventType GetType() const;

    //return button that just pressed or released
    EMouseButton GetButton() const;

    //only trigger when the button pressed twice,not button up
    bool IsDoubleClick() const;


    //only valid for WheelRoll event , positive is wheel forward ,negative is wheel backward
    int64_t GetWheeledDistance() const;

    //only valid for move event
    SIntPoint GetMoveDistance() const;

    //only for drop file/mouse move  event
    //when user drag some file in window ,this function will return true
    RFUNCTION()
    bool HaveFiles() const;

    //only for drop file/mouse move  event
    RFUNCTION()
    TVector<SPath> GetFilePaths() const;    

    //mouse event always send to capture first,will be useful when drag something;
    static TDelegate<bool,const SMouseButtonEvent &> MouseCapturer;

    static SMouseState State;
protected:

#ifdef LINUX
    friend class CLinuxPlatform;
#endif

#ifdef WIN32
    friend class CWindowsProcedure;
    friend class CWindowsPlatform;
#endif


};